//
//  AppDelegate.m
//  Confusion
//
//  Created by chuangqi on 2021/5/6.
//

#import "AppDelegate.h"
#import "ConfusionModel.h"
#import "ConfusionTools.h"

@interface AppDelegate ()

@property (strong) IBOutlet NSWindow *window;


@property (nonatomic,strong) ConfusionModel *confusionModel;
@property (nonatomic,strong) ConfusionTools *confusionTools;

/** 项目路径 */
@property (weak) IBOutlet NSComboBox *project_path;
/** 项目文件名修改 */
@property (weak) IBOutlet NSButton *project_name_status;
@property (weak) IBOutlet NSTextField *old_project_name;
@property (weak) IBOutlet NSTextField *change_project_name;

/** 项目类名前缀修改 */
@property (weak) IBOutlet NSButton *prefix_status;
@property (weak) IBOutlet NSTextField *old_prefix_name;
@property (weak) IBOutlet NSTextField *change_prefix_name;

/** 项目类名前缀修改 */
@property (weak) IBOutlet NSTextField *ignore_list;

/** 垃圾代码生成配置   */
@property (weak) IBOutlet NSButton *spam_code_out;
@property (weak) IBOutlet NSTextField *out_parameter_name;
@property (weak) IBOutlet NSTextField *spam_code_funcation_call_name;
@property (weak) IBOutlet NSTextField *change_class_funcation_call_name;

/** 修改图片名   */
@property (weak) IBOutlet NSButton *handle_xcassets;
/** 删除注释   */
@property (weak) IBOutlet NSButton *need_delete_comments;


@property (unsafe_unretained) IBOutlet NSTextView *msg_text_view;

@end


@implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    // Insert code here to initialize your application
    

}
/** 点击开始 */
- (IBAction)click_begin_button:(id)sender {
    
    
    self.confusionModel = [[ConfusionModel alloc]init];
    
    self.confusionModel.projectPath = @"/Users/chuangqi/Documents/工具App/未分类/密码本";
    
    self.confusionModel.handleXcassets = YES;
//    self.confusionModel.needDeleteComments = self.need_delete_comments.state;
    
    self.confusionModel.modifyProjectName = YES;
    self.confusionModel.oldProjectName = @"PassWord";
    self.confusionModel.changeProjectName = @"KYSHPassWord";
    
    self.confusionModel.modifyClassNamePrefix = YES;
    self.confusionModel.oldClassNamePrefix = @"IJILIMIVIR";
    self.confusionModel.changeClassNamePrefix = @"SuperHUSJFOSN_";
    
    self.confusionModel.ignoreDirNames = @"";
    
    self.confusionModel.spamCodeOut = YES;
    self.confusionModel.gOutParameterName = @"WhoIsDid";
    self.confusionModel.gSpamCodeFuncationCallName = @"runu";
    self.confusionModel.gNewClassFuncationCallName = @"runs";
    
    [self.confusionTools beginParams:self.confusionModel];
    
}

-(void)reloadModel{
    self.confusionModel = [[ConfusionModel alloc]init];
    
    self.confusionModel.projectPath = self.project_path.stringValue;
    
    self.confusionModel.handleXcassets = self.handle_xcassets.state;
//    self.confusionModel.needDeleteComments = self.need_delete_comments.state;
    
    self.confusionModel.modifyProjectName = self.project_name_status.isEnabled;
    self.confusionModel.oldProjectName = self.old_project_name.stringValue;
    self.confusionModel.changeProjectName = self.change_project_name.stringValue;
    
    self.confusionModel.modifyClassNamePrefix = self.prefix_status.state;
    self.confusionModel.oldClassNamePrefix = self.old_prefix_name.stringValue;
    self.confusionModel.changeClassNamePrefix = self.change_prefix_name.stringValue;
    
    self.confusionModel.ignoreDirNames = self.ignore_list.stringValue;
    
    self.confusionModel.spamCodeOut = self.spam_code_out.state;
    self.confusionModel.gOutParameterName = self.out_parameter_name.stringValue;
    self.confusionModel.gSpamCodeFuncationCallName = self.spam_code_funcation_call_name.stringValue;
    self.confusionModel.gNewClassFuncationCallName = self.change_class_funcation_call_name.stringValue;

}


- (void)applicationWillTerminate:(NSNotification *)aNotification {
    // Insert code here to tear down your application
}

-(ConfusionModel *)confusionModel{
    if (!_confusionModel){
        _confusionModel = [[ConfusionModel alloc]init];
    }
    return _confusionModel;
}
-(ConfusionTools *)confusionTools{
    if (!_confusionTools){
        _confusionTools = [[ConfusionTools alloc]init];
        __weak typeof(self) weakSelf = self;
        [_confusionTools setPutString:^(NSString *str, NSError *error) {
            weakSelf.msg_text_view.string = [NSString stringWithFormat:@"%@\n%@",weakSelf
                                             .msg_text_view.string,str];
        }];
    }
    return _confusionTools;
}

@end
